import Vue from "vue";
import VueI18n from "vue-i18n";
// el lang
import enLocale from "element-ui/lib/locale/lang/en";
import jaLocale from "element-ui/lib/locale/lang/ja";
import thLocale from "element-ui/lib/locale/lang/th";
import koLocale from "element-ui/lib/locale/lang/ko";
import idLocale from "element-ui/lib/locale/lang/id";
import trLocale from "element-ui/lib/locale/lang/tr-TR";
import arLocale from "element-ui/lib/locale/lang/ar";
import hiLocale from "element-ui/lib/locale/lang/he";
import viLocale from "element-ui/lib/locale/lang/vi";
import zhHansLocale from "element-ui/lib/locale/lang/zh-CN";
import zhHantLocale from "element-ui/lib/locale/lang/zh-TW";
import locale from "element-ui/lib/locale";
// lang
import en from "./en.json";
import ja from "./ja.json";
import th from "./th.json";
import zhHans from "./zh-Hans.json";
import zhHant from "./zh-Hant.json";
import ko from "./ko.json";
import id from "./id.json";
import tr from "./tr.json";
import ar from "./ar.json";
import hi from "./hi.json";
import vi from "./vi.json";

Vue.use(VueI18n);
const messages = {
  "zh-Hans": {
    ...zhHans,
    ...zhHansLocale
  },
  "zh-Hant": {
    ...zhHant,
    ...zhHantLocale
  },
  en: {
    ...en,
    ...enLocale
  },
  ja: {
    ...ja,
    ...jaLocale
  },
  th: {
    ...th,
    ...thLocale
  },
  ko: {
    ...ko,
    ...koLocale
  },
  id: {
    ...id,
    ...idLocale
  },
  tr: {
    ...tr,
    ...trLocale
  },
  ar: {
    ...ar,
    ...arLocale
  },
  hi: {
    ...hi,
    ...hiLocale
  },
  vi: {
    ...vi,
    ...viLocale
  }
};
const i18n = new VueI18n({
  locale: localStorage.getItem("lang") || "en",
  messages,
  silentTranslationWarn: true
});

locale.i18n((key, value) => i18n.t(key, value));

export default i18n;
